function lc(path, flag)
% lower case the files in a directory (recursively)
% path is the path to look at
% flags are 't' for test, 'x' for execute
%
a=ls(sprintf('-R %s', path)); % get the directory
% convert it
thisdir = path;
rem=deblank(a);
nf = 0;
while (~isempty(rem))
	[b, rem]=strtok(rem);
	if(isempty(b))
		break;
	end;
	c=deblank(b);
	if(c(length(c))~=':') % signals a directory
		n=lower(b);
		if(~strcmp(n, b))
			switch flag
			case 't'
					disp(sprintf('    (%s -> %s/%s)', b, thisdir, n))
					nf=nf+1;
			case 'x'
					disp(sprintf('    (%s -> %s/%s)', b, thisdir, n))
					eval(sprintf('!mv %s/%s %s/%s', thisdir, b, thisdir, n))
					nf=nf+1;
			 otherwise
				disp('flags: t for test, x for execute')
			end;
		end;
	else
		disp(sprintf('In directory %s ', b))
		thisdir = b(1:length(b)-1);
	end;
end;
if(nf==0)
	disp('No files to move/No files moved')
else
	disp(sprintf('%d files moved', nf))
end
		
